// created by noellynch
// Mar 10, 2011

package com.apachepivot.utils.applications;

import java.net.URI;
import java.net.URL;

import org.apache.pivot.beans.BXMLSerializer;
import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Frame;

import com.apachepivot.utils.BXMLUtils;

public class FrameBasedDesktopApplication extends BaseDesktopApplication {
	static	private		URL		mcl_frameBXML = null;
	
	private		Frame		mcl_mainFrame;
	
	@Override
	public boolean shutdown(boolean arg0) throws Exception {
		if(mcl_mainFrame != null) {
			mcl_mainFrame.close();
		}
		return false;
	}

	@Override
	public void startup(Display arg0, Map<String, String> arg1) throws Exception {
		mcl_mainFrame = BXMLUtils.readObject(mcl_frameBXML);
		mcl_mainFrame.open(arg0);
	}

	static	public	void	frameBasedApplicationMain(URL cl_frameBXML, Class<? extends Application> cl_class, Properties cl_props) {
		mcl_frameBXML = cl_frameBXML;
		BaseDesktopApplication.desktopMain(cl_class, cl_props);
	}
	
	static	public	void	frameBasedApplicationMain(URL cl_frameBXML, Properties cl_props) {
		frameBasedApplicationMain(cl_frameBXML, FrameBasedDesktopApplication.class, cl_props);
	}
}
